package MOLE;

/** 
 file ��ժҪ˵����
*/
public class file
{
	//51_A_s_p_xԴ�����ר��
	public file()
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
	}

	//51_A_s_p_xԴ�����ר��
	public static void write(String strMessage)
	{
	}
	//���ļ�
	public static String read(String filename)
	{
		FileStream o = File.OpenRead(filename);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] data = new byte[o.Length];
		byte[] data = new byte[o.getLength()];
		o.Read(data, 0, (int)o.getLength());


		String s = System.Text.Encoding.UTF8.GetString(data, 0, (int)o.getLength());
		o.Flush();
		o.Close();

		return s;
	}
	//д�ļ�
	public static void write(String txtFilePath, String strMessage)
	{
		String path = txtFilePath;
		String dir = Directory.GetParent(path).toString();
		if (!(new java.io.File(dir)).isDirectory())
		{
			(new java.io.File(dir)).mkdirs();
		}

		StreamWriter writer = new StreamWriter(path, true, System.Text.Encoding.UTF8);


		writer.WriteLine(strMessage);

		writer.Flush();

		writer.Close();
	}

	public static void ClearWrite(String txtFilePath, String strMessage)
	{
		String path = txtFilePath;
		String dir = Directory.GetParent(path).toString();
		if (!(new java.io.File(dir)).isDirectory())
		{
			(new java.io.File(dir)).mkdirs();
		}

		StreamWriter writer = new StreamWriter(path, false);


		writer.Write(strMessage);

		writer.Flush();

		writer.Close();

	}

	public static void ClearWrite(String txtFilePath, String strMessage, String encode)
	{
		String path = txtFilePath;
		String dir = Directory.GetParent(path).toString();
		if (!(new java.io.File(dir)).isDirectory())
		{
			(new java.io.File(dir)).mkdirs();
		}

		StreamWriter writer = new StreamWriter(path, false, System.Text.Encoding.GetEncoding(encode));


		writer.Write(strMessage);

		writer.Flush();

		writer.Close();

	}

	public static void delete(String filename)
	{


	}
	public static void log(String msg)
	{
		String s = System.Web.HttpContext.Current.Server.MapPath("./");
		s = s + "_log/log.txt";
		String path = s;
		MOLE.file.write(path, msg);

	}


}